package com.majie.algorithm.stack;

import com.majie.algorithm.dynamic_array.ArrayList;

public class Stack<E> {

    private ArrayList<E> list = new ArrayList<>();

    public void push(E element) {
        list.add(element);
    }

    public E pop( ) {
        E element = list.get(list.size() - 1);
        list.remove(list.size() - 1);
        return element;
    }

    public E peek( ) {
        return list.get(list.size() - 1);
    }

    public int size( ) {
        return this.list.size();
    }
}
